package com.rocksea.app.db.image;


import android.os.Parcel;
import android.os.Parcelable;

import com.litesuits.orm.db.annotation.Default;
import com.litesuits.orm.db.annotation.PrimaryKey;
import com.litesuits.orm.db.annotation.Table;
import com.litesuits.orm.db.enums.AssignType;
import com.rocksea.app.entry.ImageInfo;
import com.rocksea.app.utils.FileHelper;
import com.rocksea.app.utils.PerUtils;

import java.util.Date;
import java.util.UUID;

/**
 * Created by 吴志华 on 2017/10/17.
 *
 */
@Table("ImageTable")
public class ImageTable implements Parcelable
{
    @PrimaryKey(AssignType.AUTO_INCREMENT)
    private int id;
    private String planNum;
    private String pileNo;
    private String creatTime;
    @Default("0")
    private long upLoadTime;
    private String remake;
    private int type;
    private long pileId;
    private String fileName;

    //0 -不是波列图  1-是波列图
    @Default("0")
    private int isSonicWave;
    private String filePath;

    private String sectionId;


    public ImageTable()
    {

    }

    public ImageTable(ImageInfo imageInfo)
    {
        planNum = imageInfo.getPlanNum();
        pileId = imageInfo.getPileId();
        pileNo = imageInfo.getPileNo();
        fileName = String.format("%s.jpg",UUID.randomUUID().toString());
        type = imageInfo.getTestType();
        remake = imageInfo.getRemake();
        creatTime = PerUtils.dateToStr(new Date());
        upLoadTime = 0;
        filePath = FileHelper.writeBitMap(imageInfo.getBitmap(),fileName);
    }

    protected ImageTable(Parcel in) {
        id = in.readInt();
        planNum = in.readString();
        pileNo = in.readString();
        creatTime = in.readString();
        upLoadTime = in.readLong();
        remake = in.readString();
        type = in.readInt();
        pileId = in.readLong();
        fileName = in.readString();
        isSonicWave = in.readInt();
        filePath = in.readString();
        sectionId = in.readString();


    }

    public static final Creator<ImageTable> CREATOR = new Creator<ImageTable>() {
        @Override
        public ImageTable createFromParcel(Parcel in) {
            return new ImageTable(in);
        }

        @Override
        public ImageTable[] newArray(int size) {
            return new ImageTable[size];
        }
    };

    public String getPlanNum()
    {
        return planNum;
    }

    public void setPlanNum(String planNum)
    {
        this.planNum = planNum;
    }

    public String getPileNo()
    {
        return pileNo;
    }

    public void setPileNo(String pileNo)
    {
        this.pileNo = pileNo;
    }

    public String getCreatTime()
    {
        return creatTime;
    }

    public void setCreatTime(String creatTime)
    {
        this.creatTime = creatTime;
    }

    public long getUpLoadTime()
    {
        return upLoadTime;
    }

    public void setUpLoadTime(long upLoadTime)
    {
        this.upLoadTime = upLoadTime;
    }

    public String getRemake()
    {
        return remake;
    }

    public void setRemake(String remake)
    {
        this.remake = remake;
    }

    public int getType()
    {
        return type;
    }

    public void setType(int type)
    {
        this.type = type;
    }

    public long getPileId()
    {
        return pileId;
    }

    public void setPileId(long pileId)
    {
        this.pileId = pileId;
    }

    public String getFileName()
    {
        return fileName;
    }

    public void setFileName(String fileName)
    {
        this.fileName = fileName;
    }

    public int getIsSonicWave() {
        return isSonicWave;
    }

    public void setIsSonicWave(int isSonicWave) {
        this.isSonicWave = isSonicWave;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public String getSectionId() {
        return sectionId;
    }

    public void setSectionId(String sectionId) {
        this.sectionId = sectionId;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags)
    {
        dest.writeInt(id);
        dest.writeString(planNum);
        dest.writeString(pileNo);
        dest.writeString(creatTime);
        dest.writeLong(upLoadTime);
        dest.writeString(remake);
        dest.writeInt(type);
        dest.writeLong(pileId);
        dest.writeString(fileName);
        dest.writeInt(isSonicWave);
        dest.writeString(filePath);
        dest.writeString(sectionId);
    }
}
